/**
 * 
 */
package com.yangtao.prototype.system.role.web;

import com.yangtao.framework.dojo.DojoDataModel;
import com.yangtao.framework.util.Struts2Utils;
import com.yangtao.framework.web.BaseAction;
import com.yangtao.prototype.system.role.service.RoleModel;
import com.yangtao.prototype.system.role.service.RoleService;

/**
 * 角色管理Action
 * 
 * @author 杨涛
 * 
 */
public class RoleAction extends BaseAction<RoleModel, RoleService> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String query() {
		return render("RoleQuery");
	}

	public String load() {
		service.load(model);
		return render("RoleDetail");
	}

	/**
	 * 加载菜单树
	 * 
	 * @return
	 */
	public String loadMenuTree() {
		service.loadMenus(model);
		DojoDataModel ddm = new DojoDataModel();
		ddm.setLabel("text");
		ddm.setItems(model.getMenu());
		Struts2Utils.renderJson(ddm, true);
		return null;
	}

	public String save() {
		service.saveRoleAuth(model);
		return renderJsonMessage();
	}

	public String list() {
		service.list(model);
		renderJson(model.getPage());
		return null;
	}

	public void prepare() {
		service.load(model);
	}

	public String delete() {
		service.delete(model);
		return renderJsonMessage();
	}
}
